# -*- coding: utf-8 -*-
# @Time    : 2018/12/11 下午6:41
# @Author  : ZhiYuanYang
# @Email   : faryangsh@163.com
# @File    : TypeAlias.py

from typing import List

# 通过将类型分配给别名来定义类型别名。在本示例中，Vector 和 List[float] 将被视为可互换的同义词:
Vector = List[float]


# vector: Vector 等同于 vector: List[float]
def scale(scalar: float, vector: Vector) -> Vector:
    return [scalar * num for num in vector]


if __name__ == '__main__':
    # typechecks; a list of floats qualifies as a Vector.
    new_vector = scale(2.0, [1.0, -4.2, 5.4])
    print(new_vector)
